//
//  XSTitleView.swift
//  SwiftProject
//
//  Created by 杨晓生 on 16/8/4.
//  Copyright © 2016年 XS. All rights reserved.
//

import UIKit

class XSTitleView: UIButton {

    
    override init(frame: CGRect) {
        super.init(frame: frame)
        
        
    }
    
    override func layoutSubviews() {
        super.layoutSubviews()
        /*这个方法调用了两次
        print("----------------")
        titleLabel?.frame.offsetInPlace(dx: -(imageView?.bounds.width)!, dy: 0)
        imageView?.frame.offsetInPlace(dx: (titleLabel?.bounds.width)!, dy: 0)
        */
        
        //oc中不能对属性直接赋值，swift中可以
        titleLabel?.frame.origin.x = 0
        imageView?.frame.origin.x = (titleLabel?.frame.size.width)!
    }
}
